"use strict";

/**
 * @ngdoc directive
 * @name jgappApp.directive:relList
 * @description
 * # relList
 */
angular
  .module("jgappApp")
  .directive("projectList", function ($location, Util, localStorageService) {
    return {
      scope: {
        formKey: "=formKey",
        data: "=data"
      },
      template:
        "<div>" +
        '<div class="section rel-list-label mt10" ng-click="goProjectList(1)"><div class="info-title">变更记录</div></div>' +
        '<div class="section rel-list-label mt10" ng-click="goProjectList(8)"><div class="info-title">合同记录</div></div>' +
        '<div class="section rel-list-label mt10" ng-click="goProjectList(12)"><div class="info-title">保证金记录</div></div>' +
        '<div class="section rel-list-label mt10" ng-click="goProjectList(2)"><div class="info-title">收款记录</div></div>' +
        '<div class="section rel-list-label mt10" ng-click="goProjectList(3)"><div class="info-title">付款记录</div></div>' +
        '<div class="section rel-list-label mt10" ng-click="goProjectList(9)"><div class="info-title">农民工工资付款记录</div></div>' +
        '<div class="section rel-list-label mt10" ng-click="goProjectList(4)"><div class="info-title">扣款记录</div></div>' +
        '<div class="section rel-list-label mt10" ng-click="goProjectList(5)"><div class="info-title">退款记录</div></div>' +
        '<div class="section rel-list-label mt10" ng-click="goProjectList(10)"><div class="info-title">借款记录</div></div>' +
        '<div class="section rel-list-label mt10" ng-click="goProjectList(11)"><div class="info-title">报销记录</div></div>' +
        '<div class="section rel-list-label mt10" ng-click="goProjectList(13)"><div class="info-title">进项发票</div></div>' +
        '<div class="section rel-list-label mt10" ng-click="goProjectList(14)"><div class="info-title">销项发票</div></div>' +
        '<div class="section rel-list-label mt10" ng-click="goProjectList(15)"><div class="info-title">缴税记录</div></div>' +
        '<div class="section rel-list-label mt10" ng-click="goProjectList(16)"><div class="info-title">抵税退税</div></div>' +
        '<div class="section rel-list-label mt10" ng-click="goProjectList(6)"><div class="info-title">清账记录</div></div>' +
        '<div class="section rel-list-label mt10" ng-click="goProjectList(7)"><div class="info-title">待清记录</div></div>' +
        "</div>",
      replace: true,
      restrict: "AE",
      link: function postLink(scope, element, attrs) {
        scope.goProjectList = function (type) {
          Util.setRelMoNum(1);
          switch (type) {
            case 1:
              $location.path("/project/modifylist/" + scope.data.pkId);
              break;
            case 2:
              $location.path("/project/gatheringlist/" + scope.data.pkId);
              break;
            case 3:
              $location.path("/project/paymentlist/" + scope.data.pkId);
              break;
            case 4:
              $location.path("/project/costlist/" + scope.data.pkId);
              break;
            case 5:
              $location.path("/project/refundlist/" + scope.data.pkId);
              break;
            case 6:
              $location.path("/project/repaylist/" + scope.data.pkId);
              break;
            case 7:
              $location.path("/project/topaylist/" + scope.data.pkId);
              break;
            case 8:
              $location.path("/project/contractlist/" + scope.data.pkId);
              break;
            case 9:
              $location.path("/project/nmggzlist/" + scope.data.pkId);
              break;
            case 10:
              $location.path("/project/lendlist/" + scope.data.pkId);
              break;
            case 11:
              $location.path("/project/reimlist/" + scope.data.pkId);
              break;
            case 12:
              $location.path("/project/bzjlist/" + scope.data.pkId);
              break;
            case 13:
              $location.path("/project/inInvoicelist/" + scope.data.pkId);
              break;
            case 14:
              $location.path("/project/outInvoicelist/" + scope.data.pkId);
              break;
            case 15:
              $location.path("/project/ratpaylist/" + scope.data.pkId);
              break;
            case 16:
              $location.path("/project/ratbondlist/" + scope.data.pkId);
              break;
            default:
              break;
          }
        };
      }
    };
  })
  .directive("paymentList", function ($location, Util, localStorageService) {
    return {
      scope: {
        formKey: "=formKey",
        data: "=data"
      },
      template:
        "<div>" +
        '<div class="section rel-list-label mt10" ng-click="goProjectList(1)"><div class="info-title">该项目最近发起申请的付款记录</div></div>' +
        '<div class="section rel-list-label mt10" ng-click="goProjectList(2)"><div class="info-title">该项目最近成功入账的收款记录</div></div>' +
        '<div class="section rel-list-label mt10" ng-click="goProjectList(3)"><div class="info-title">该项目最近等待结算的扣款记录</div></div>' +
        "</div>",
      replace: true,
      restrict: "AE",
      link: function postLink(scope, element, attrs) {
        scope.goProjectList = function (type) {
          Util.setRelMoNum(1);
          localStorageService.set("projectData", scope.data);
          switch (type) {
            case 1:
              $location.path(
                "/project/recentpaymentlist/" +
                scope.data.pkId +
                "/" +
                scope.data.projectId
              );
              break;
            case 2:
              $location.path(
                "/project/recentgatheringlist/" + scope.data.projectId
              );
              break;
            case 3:
              $location.path("/project/topaylist/" + scope.data.projectId);
              break;
            default:
              break;
          }
        };
      }
    };
  })
  .directive("gatherList", function ($location, Util) {
    return {
      scope: {
        formKey: "=formKey",
        data: "=data"
      },
      template:
        '<div><div class="section rel-list-label mt10" ng-click="goRelList(1)"><div class="info-title">退回记录</div></div>' +
        '<div class="section rel-list-label mt10" ng-click="goRelList(2)"><div class="info-title">该项目的其他收款记录</div></div></div>',
      replace: true,
      restrict: "AE",
      link: function postLink(scope, element, attrs) {
        scope.goRelList = function (type) {
          Util.setRelMoNum(1);
          switch (type) {
            case 1:
              $location.path(
                "/project/refundlist2/" + scope.data.pkId + "/" + scope.formKey
              );
              break;
            case 2:
              $location.path(
                "/project/gatheringlist/" +
                scope.data.projectId +
                "/" +
                scope.data.pkId
              );
              break;
            default:
              break;
          }
        };
      }
    };
  })
  .directive("refundList", function ($location, Util) {
    return {
      scope: {
        formKey: "=formKey",
        data: "=data"
      },
      template:
        '<div class="section rel-list-label mt10" ng-click="goRelList()"><div class="info-title">该项目的其他退款记录</div></div>',
      replace: true,
      restrict: "AE",
      link: function postLink(scope, element, attrs) {
        scope.goRelList = function () {
          Util.setRelMoNum(1);
          $location.path(
            "/project/refundlist/" +
            scope.data.projectId +
            "/" +
            scope.data.pkId
          );
        };
      }
    };
  })
  .directive("costList", function ($location, Util) {
    return {
      scope: {
        formKey: "=formKey",
        data: "=data"
      },
      template:
        '<div><div class="section rel-list-label mt10" ng-click="goRelList(1)"><div class="info-title">退回记录</div></div>' +
        '<div class="section rel-list-label mt10" ng-click="goRelList(2)"><div class="info-title">该项目的其他扣款记录</div></div></div>',
      replace: true,
      restrict: "AE",
      link: function postLink(scope, element, attrs) {
        scope.goRelList = function (type) {
          Util.setRelMoNum(1);
          switch (type) {
            case 1:
              $location.path(
                "/project/refundlist2/" + scope.data.pkId + "/" + scope.formKey
              );
              break;
            case 2:
              $location.path(
                "/project/costlist/" +
                scope.data.projectId +
                "/" +
                scope.data.pkId
              );
              break;
            default:
              break;
          }
        };
      }
    };
  })
  .directive("balanceList", function ($location, Util) {
    return {
      scope: {
        formKey: "=formKey",
        data: "=data"
      },
      template:
        '<div class="section rel-list-label mt10" ng-click="goRelList()"><div class="info-title">该项目的其他清账记录</div></div>',
      replace: true,
      restrict: "AE",
      link: function postLink(scope, element, attrs) {
        scope.goRelList = function (type) {
          Util.setRelMoNum(1);
          $location.path(
            "/project/topaylist/" + scope.data.projectId + "/" + scope.data.pkId
          );
        };
      }
    };
  })
  .directive("relList", function ($location, Util, localStorageService) {
    return {
      scope: {
        formKey: "=formKey",
        data: "=data"
      },
      template:
        '<div class="section rel-list-label mt10" ng-click="goRelList()"><div class="info-title">关联模块</div></div>',
      replace: true,
      restrict: "AE",
      link: function postLink(scope, element, attrs) {
        scope.goRelList = function () {
          localStorageService.set("relData", scope.data);
          Util.setRelMoNum(1);
          $location.path("relmodule/index/" + scope.formKey);
        };
      }
    };
  })
  .directive("fileModule", function ($location) {
    return {
      scope: {
        formKey: "=formKey",
        refId: "=refId"
      },
      template:
        '<div class="section rel-list-label mt10" ng-click="goFileMOdule()"><div class="info-title">文件夹</div></div>',
      replace: true,
      restrict: "AE",
      link: function postLink(scope) {
        scope.goFileMOdule = function () {
          $location.path(
            "filemodule/index/" + scope.refId + "/" + scope.formKey
          );
        };
      }
    };
  })
  .directive("zjhistory", function ($location, Util) {
    return {
      scope: {
        cerId: "=cerid"
      },
      template:
        "<div>" +
        '<div class="section rel-list-label mt10" ng-click="goRelList(1)"><div class="info-title">借证记录</div></div>' +
        '<div class="section rel-list-label mt10" ng-click="goRelList(2)"><div class="info-title">还证记录</div></div>' +
        "</div>",
      replace: true,
      restrict: "AE",
      link: function postLink(scope) {
        scope.goRelList = function (type) {
          Util.setRelMoNum(1);
          console.log(scope.cerId);
          $location.path(
            "/administrator/zjhistory/" + type + "/" + scope.cerId
          );
        };
      }
    };
  })
  .directive("supplyAgreement", function ($location, Util, localStorageService) {
    return {
      scope: {
        data: "=data"
      },
      template:
        '<div>' +
        '<div><div class="section rel-list-label mt10" ng-click="goRelList(1)"><div class="info-title">该合同支付工程款的记录</div></div>' +
        '<div><div class="section rel-list-label mt10" ng-click="goRelList(2)"><div class="info-title">该合同开具进项票的记录</div></div>' +
        '<div><div class="section rel-list-label mt10" ng-click="goRelList(3)"><div class="info-title">该合同已生效的补充协议</div></div>' +
        '</div>',
      replace: true,
      restrict: "AE",
      link: function postLink(scope, element, attrs) {
        scope.goRelList = function (type) {
          Util.setRelMoNum(1);
          localStorageService.set("contractRecordParam", {
            contractType: attrs.contracttype,
            projectId: scope.data.projectId,
            contractNo: scope.data.fileNo,
            completion: 1
          });
          switch (type) {
            case 1:
              $location.path(
                "/contract/paymentlist"
              );
              break;
            case 2:
              $location.path(
                "/contract/invoicelist"
              );
              break;
            case 3:
              $location.path(
                "/contract/supplylist"
              );
              break;
            default:
              break;
          }

        };
      }
    };
  })
